import pymysql

db = pymysql.connect(host="127.0.0.1", port=3306, db="ds0", user="root", password="111111")

# 创建游标对象
cursor = db.cursor()

# cursor.execute("select version()")

cursor.execute("drop table if exists user")

# 创建表
sql = """
CREATE TABLE `user` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `user_name` varchar(128) NOT NULL DEFAULT '' COMMENT '用户名',
  `age` int NOT NULL COMMENT '年龄',
  `address` varchar(128) DEFAULT NULL COMMENT '地址',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户表';
"""

cursor.execute(sql)

# data = cursor.fetchone()

# print("查询结果：", data)

# 关闭连接

db.close()
